package com.dba.example.guice.web.logging;

import java.util.logging.Level;
import java.util.logging.LogRecord;

import javax.inject.Singleton;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gwt.logging.shared.RemoteLoggingService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

@Singleton
public class RemoteLoggingServiceImpl extends RemoteServiceServlet implements
		RemoteLoggingService {

	private static final long serialVersionUID = 1L;

	private static final Logger LOG = LoggerFactory.getLogger(RemoteLoggingServiceImpl.class);
	
	@Override
	public String logOnServer(LogRecord record) {
		if (Level.SEVERE.equals(record.getLevel())) {
			LOG.error(record.getMessage());
		} else if (Level.WARNING.equals(record.getLevel())) {
			LOG.warn(record.getMessage());
		} else if (Level.INFO.equals(record.getLevel())) {
			LOG.info(record.getMessage());
		} else if (Level.CONFIG.equals(record.getLevel())) {
			LOG.info(record.getMessage());
		} else if (Level.FINE.equals(record.getLevel())) {
			LOG.trace(record.getMessage());
		} else if (Level.FINEST.equals(record.getLevel())) {
			LOG.trace(record.getMessage());
		} else if (Level.ALL.equals(record.getLevel())) {
			LOG.trace(record.getMessage());
		}
		return null;
	}

}
